#include "Transform.h"
#include "Config.h"

void Transform::init() {
	world.setMatrixIdentity();
	view.setMatrixIdentity();
	projection.setPerspective(PI * 0.5f, WINDOW_WIDTH / WINDOW_HEIGHT, 1, 500);

	light.direction = Vector(0, 0, 5);
	light.color = Vector(1, 1, 1);
	light.direction.normalize();
	light.materialSpecColor = Vector(2, 2, 2);
	light.shine = 5;
	update();
}
void Transform::update() {
	wv = world * view;
	wvp = wv * projection;
}
void Transform::setView(const Vector& eye) {
	this->eye = eye;
	Vector at(0, 0, 0, 1.);
	Vector up(0, 1, 0, 1);
	view.setLookAt(eye, at, up);
	update();
}
void Transform::changeView(const Matrix& mat) {
	view = view * mat;
	update();
}
void Transform::setWorld(const Matrix& m) {
	world = m;
	update();
}

void Transform::changeWorld(const Matrix &m) {
	world = world * m;
	update();
}
